package com.kaigejava.singleton;

/**
 * Created by kaigejava on 2019/8/21.
 * 懒汉式同步锁
 */
public class SingletonThree {
    private static  SingletonThree singletonThree = null;

    private  SingletonThree (){}

    /**
     * 懒汉式同步锁获取方式
     * 就是在懒汉式中添加了锁对象
     * @return
     */
    public static SingletonThree getInstance(){
        synchronized (SingletonThree.class){
            if(null == singletonThree){
                singletonThree = new SingletonThree();
            }
        }
        return singletonThree;
    }
}
